#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Author  : yanxiang
# @Software: PyCharm
from rest_framework import serializers

from goods.models import Goods,GoodsCategory


class CategorySerializer3(serializers.ModelSerializer):
    class Meta:
        model = GoodsCategory
        fields ="__all__"


class CategorySerializer2(serializers.ModelSerializer):
    sub_cat = CategorySerializer3(many=True)
    class Meta:
        model = GoodsCategory
        fields ="__all__"


class CategorySerializer(serializers.ModelSerializer):
    #many=True代表一类下面有许多二类
    sub_cat = CategorySerializer2(many=True)
    class Meta:
        model = GoodsCategory
        fields ="__all__"


class GoodSerializers(serializers.ModelSerializer):
    category = CategorySerializer()
    class Meta:
        model = Goods
        fields ="__all__"